package main

import (
	"fmt"
)

func main() {
	var num1 int = 10
	var num2 int = 20
	fmt.Printf("交换前： num1: %v, num2: %v \n", num1, num2)
	exchang(num1, num2)
	fmt.Printf("交换后： num1: %v, num2: %v \n", num1, num2)
	exchang2(&num1, &num2)
	fmt.Printf("交换后： num1: %v, num2: %v \n", num1, num2)

}

func exchang(num1 int, num2 int) {
	var temp int = num1
	num1 = num2
	num2 = temp
}

func exchang2(num1 *int, num2 *int) {
	var temp int = *num1
	*num1 = *num2
	*num2 = temp
}

